package operator;

import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * project 算子 映射
 */
public class ProjectDemo {

    public static void main(String[] args) throws Exception{
        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());

        DataStreamSource<Tuple3<String, String, String>> elements = env.fromElements(Tuple3.of("1", "中国", "china"), Tuple3.of("2", "美国", "the usa"));

        // 取出tuple中指定下标的元素 java python中才有 在Scala中一个map搞定 下标从0开始
        SingleOutputStreamOperator<Tuple> project = elements.project(1, 2);

        project.print();

        env.execute("project transformation");
    }
}
